﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;
using System.Data;
using HF.WorkFlow.Engine;
using HF.WorkFlow.Template;
using HF.WCF.WFInterface;
using HF.WorkFlow.Const;
using HF.Forms.Data;
using HF.WorkFlow.DataContract;
using HF.Framework.Log;
using HF.Architecture.Data;
using HF.Business.Common;
using HF.WorkFlow.DataContract.WorkFlow;
namespace HF.WCF.WFService
{
    public class WorkFlowService:IWorkFlowService
    {
        AuditMessage auditmessage = new AuditMessage();
        AffixFiles affixfiles = new AffixFiles();
        WorkAgency agency = new WorkAgency();
        WorkTaskInstanceNextOperEntity nextoper = new WorkTaskInstanceNextOperEntity();
        public string Start(string userId, string workFlowId, string workTaskId,
                            string workFlowInstanceId, string workTaskInstanceId, string workflowno, string command, string priority, string workflowInsCaption, bool isDraft)
        {
            WorkFlowRuntime wfruntime = new WorkFlowRuntime();
            wfruntime.UserId = userId;//当前操作人id
            wfruntime.WorkFlowInstanceId = workFlowInstanceId;
            wfruntime.WorkTaskInstanceId = workTaskInstanceId;
            wfruntime.WorkFlowId = workFlowId;
            wfruntime.WorkTaskId = workTaskId;
            wfruntime.WorkFlowNo = workflowno;
            wfruntime.CommandName = command;//命令分支，必须与建模中的命令定义名相同，否则无法流转
            wfruntime.Priority = priority;
            wfruntime.WorkflowInsCaption = workflowInsCaption;
            wfruntime.IsDraft = isDraft;//true 表示保存草稿,执行start方法的时候流程不流转
            return wfruntime.Start();//启动流程  
        }
        public string Run(string userId, string operatorInsId, string commandName)
        {
            WorkFlowRuntime wfruntime = new WorkFlowRuntime();
            return wfruntime.Run(userId, operatorInsId, commandName);//命令分支，必须与建模中的命令定义名相同，否则无法流转
        }


        public string SetSuspend(string workflowInsId)//流程挂起
        {
            return WorkFlowInstance.SetSuspend(workflowInsId);
        }

        public string SetResume(string workflowInsId)//取消挂起
        {
            return WorkFlowInstance.SetResume(workflowInsId);

        }
        public string SetAbnormal(string workflowInsId, string userId, string msg)//异常终止
        {
            return WorkFlowInstance.SetAbnormal(workflowInsId, userId, msg);
        }
        public List<WorkTaskViewEntity> GetAllowsStartWorkFlowEntitys(string userId)
        {
            return WorkFlowTemplate.GetInstance().GetAllowsStartWorkFlowEntitys(userId);
        }

        public string GetToDoWorkTaskJson(string userId, int pageIndex, int pageSize)
        {
            return WorkFlowInstance.GetInstance().GetToDoWorkTaskJson(userId, pageIndex, pageSize);
        }

        public List<WorkTaskInstanceViewEntity> GetTodoWorkTaskEntity(string userId, int pageIndex, int pageSize)
        {
            return WorkFlowInstance.GetInstance().GetTodoWorkTaskEntity(userId, pageIndex, pageSize);
        }

        public string GetClaimWorkTaskJson(string userId, int pageIndex, int pageSize)
        {
            return WorkFlowInstance.GetInstance().GetClaimWorkTaskJson(userId, pageIndex, pageSize);
        }

        public List<WorkTaskInstanceViewEntity> GetClaimWorkTaskEntity(string userId, int pageIndex, int pageSize)
        {
            return WorkFlowInstance.GetInstance().GetClaimWorkTaskEntity(userId, pageIndex, pageSize);
        }

        public string GetAllWorkTaskJson(string userId, int pageIndex, int pageSize)
        {
            return WorkFlowInstance.GetInstance().GetAllWorkTaskJson(userId, pageIndex, pageSize);
        }

        public List<WorkTaskInstanceViewEntity> GetAllWorkTaskEntity(string userId, int pageIndex, int pageSize)
        {
            return WorkFlowInstance.GetInstance().GetAllWorkTaskEntity(userId, pageIndex, pageSize);
        }

        public string GetClaimedWorkTaskJson(string userId, int pageIndex, int pageSize)
        {
            return WorkFlowInstance.GetInstance().GetClaimedWorkTaskJson(userId, pageIndex, pageSize);
        }

        public List<WorkTaskInstanceViewEntity> GetClaimedWorkTaskEntity(string userId, int pageIndex, int pageSize)
        {
            return WorkFlowInstance.GetInstance().GetClaimedWorkTaskEntity(userId, pageIndex, pageSize);
        }

        public string GetRunningInstanceJson(int pageIndex, int pageSize)
        {
            return WorkFlowInstance.GetInstance().GetRunningInstanceJson(pageIndex, pageSize);
        }

        public List<WorkFlowInstanceEntity> GetRunningInstanceEntity(int pageIndex, int pageSize)
        {
            return WorkFlowInstance.GetInstance().GetRunningInstanceEntity(pageIndex, pageSize);
        }

        public string GetCompletedInstanceJson(int pageIndex, int pageSize)
        {
            return WorkFlowInstance.GetInstance().GetCompletedInstanceJson(pageIndex, pageSize);
        }

        public List<WorkFlowInstanceEntity> GetCompletedInstanceEntity(int pageIndex, int pageSize)
        {
            return WorkFlowInstance.GetInstance().GetCompletedInstanceEntity(pageIndex, pageSize);
        }

        public string GetCompletedWorkTaskJson(string userId, int pageIndex, int pageSize)
        {
            return WorkFlowInstance.GetInstance().GetCompletedWorkTaskJson(userId, pageIndex, pageSize);
        }

        public List<WorkTaskInstanceViewEntity> GetCompletedWorkTaskEntity(string userId, int pageIndex, int pageSize)
        {
            return WorkFlowInstance.GetInstance().GetCompletedWorkTaskEntity(userId, pageIndex, pageSize);
        }

        public string GetAbnormalInstanceJson(int pageIndex, int pageSize)
        {
            return WorkFlowInstance.GetInstance().GetAbnormalInstanceJson(pageIndex, pageSize);
        }

        public List<WorkFlowInstanceEntity> GetAbnormalInstanceEntity(int pageIndex, int pageSize)
        {
            return WorkFlowInstance.GetInstance().GetAbnormalInstanceEntity(pageIndex, pageSize);
        }

        public string GetSuspendInstanceJson(int pageIndex, int pageSize)
        {
            return WorkFlowInstance.GetInstance().GetSuspendInstanceJson(pageIndex, pageSize);
        }

        public List<WorkFlowInstanceEntity> GetSuspendInstanceEntity(int pageIndex, int pageSize)
        {
            return WorkFlowInstance.GetInstance().GetSuspendInstanceEntity(pageIndex, pageSize);
        }

        public string GetAbnormalWorkTaskJson(string userId, int pageIndex, int pageSize)
        {
            return WorkFlowInstance.GetInstance().GetAbnormalWorkTaskJson(userId, pageIndex, pageSize);
        }

        public List<WorkTaskInstanceViewEntity> GetAbnormalWorkTaskEntity(string userId, int pageIndex, int pageSize)
        {
            return WorkFlowInstance.GetInstance().GetAbnormalWorkTaskEntity(userId, pageIndex, pageSize);
        }

        public string GetSuspendWorkTaskJson(string userId, int pageIndex, int pageSize)
        {
            return WorkFlowInstance.GetInstance().GetSuspendWorkTaskJson(userId, pageIndex, pageSize);
        }

        public List<WorkTaskInstanceViewEntity> GetSuspendWorkTaskEntity(string userId, int pageIndex, int pageSize)
        {
            return WorkFlowInstance.GetInstance().GetSuspendWorkTaskEntity(userId, pageIndex, pageSize);
        }

        public int GetClaimTaskCount(string userId)
        {
            return WorkFlowInstance.GetInstance().GetClaimTaskCount(userId);
        }

        public int GetToDoTasksCount(string userId)
        {
            return WorkFlowInstance.GetInstance().GetToDoTasksCount(userId);
        }

        public int GetClaimedTaskCount(string userId)
        {
            return WorkFlowInstance.GetInstance().GetClaimTaskCount(userId);
        }

        public int GetAllTaskCount(string userId)
        {
            return WorkFlowInstance.GetInstance().GetAllTaskCount(userId);
        }

        public int GetCompletedTaskCount(string userId)
        {
            return WorkFlowInstance.GetInstance().GetCompletedTaskCount(userId);
        }

        public int GetAbnormalTaskCount(string userId)
        {
            return WorkFlowInstance.GetInstance().GetAbnormalTaskCount(userId);
        }

        public string GetWorkFlowNO()
        {
            return WorkFlowInstance.GetWorkFlowNO();
        }

        public string GetDBDateTime()
        {
            return WorkFlowInstance.GetDBDateTime();
        }


        public List<LogEntity> GetLogEntitys(DateTime startTime, DateTime endTime)
        {
            return LogData.GetInstance().GetLogEntitys(startTime, endTime);

        }
        public WorkFlowEntity GetWorkFlowEntity(string workFlowId)    //zhuyun 20120209
        {
            return WorkFlowTemplate.GetInstance().GetWorkFlowEntity(workFlowId);
        }
        public DataTable GetWorkTaskFormsView(string workTaskId)      //zhuyun 20120209 获得任务节点与表单的视图信息
        {
            return MainChildForm.GetInstance().GetWorkTaskFormsView(workTaskId);
        }
        public DataTable GetTaskCommands(string WorktaskId)
        {
            return WorkTaskCommand.GetInstance().GetTaskCommands(WorktaskId);  //zhuyun 20120209  获得任务节点的所有命令
        }
        public DataTable GetAllowsStartWorkFlows(string userId)      //获取可以启动的流程 返回Datable   zhuyun
        {
            return WorkFlowTemplate.GetInstance().GetAllowsStartWorkFlows(userId);
        }
        public DataTable GetOperatorInstanceView(string operatorInstanceId)
        {
            return OperatorInstance.GetInstance().GetOperatorInstanceView(operatorInstanceId);
        }
        public DataTable GetTaskPowers(string workTaskId)
        {
            return WorkTaskPower.GetInstance().GetTaskPowers(workTaskId);
        }
        public string TaskBack(string userId, string operatorInstanceId)      //退回事件
        {
            WorkFlowRuntime wfruntime = new WorkFlowRuntime();
            return wfruntime.TaskBack(userId, operatorInstanceId);
        }
        public string TaskUnClaim(string userId, string operatorInstanceId)    //放弃认领
        {
            WorkFlowRuntime wfruntime = new WorkFlowRuntime();
            return wfruntime.TaskUnClaim(userId, operatorInstanceId);
        }
        public string TaskClaim(string userId, string operatorInstanceId)     //认领任务
        {
            WorkFlowRuntime wfruntime = new WorkFlowRuntime();
            return wfruntime.TaskClaim(userId, operatorInstanceId);
        }
        public DataTable GetAuditMsgTableByFlow(string workflowInsId)        //获得流程实例的审批列表 
        {
            return auditmessage.GetAuditMsgTableByFlow(workflowInsId);
        }
        public DataTable GetAuditMsgTableByOper(string operatorInsId)       //获得操作实例审批列表
        {
            return auditmessage.GetAuditMsgTableByOper(operatorInsId);
        }
        public void InsertAuditMessage(AuditMessage entity)                  //插入审批信息
        {
            auditmessage.InsertAuditMessage(entity);
        }
        public void UpdateAuditMessage(AuditMessage entity)                   //更新审批信息
        {
            auditmessage.UpdateAuditMessage(entity);
        }
        public DataTable GetWorkTasks(string workFlowId)      //获得流程模板的所有任务节点 
        {
            return WorkTask.GetInstance().GetWorkTasks(workFlowId);
        }
        public DataTable GetTaskInstanceUser(string workFlowInstanceId, string workTaskId) // 某一任务实际处理者
        {
            return WorkTaskInstance.GetInstance().GetTaskInstanceUser(workFlowInstanceId, workTaskId);
        }
        public string GetExistsTaskInstance(string workTaskId, string pWorkTaskInstanceId) //  判断当前任务节点的实例在流程实例中是否已经产生。主要是针对控制节点实例的判断。
        {
            return WorkTaskInstance.GetInstance().GetExistsTaskInstance(workTaskId, pWorkTaskInstanceId);
        }

        public DataTable GetNetTaskFormID(string PreviousTaskInstanceIde, string workTaskId) 
        {
            return WorkTaskInstance.GetInstance().GetNetTaskFormID(PreviousTaskInstanceIde, workTaskId);
        }
        public bool IsPassJudge(string workFlowId, string workFlowInstanceId, string judgeTaskId, string taskTypeAndOr) //判断节点实例是否都完成
        {
            return WorkFlowHelper.IsPassJudge(workFlowId, workFlowInstanceId, judgeTaskId, taskTypeAndOr);
        }
        public bool IsCurrentTask(string workFlowInstanceId, string workTaskId)   // 判断任务节点是否正在执行
        {
            return WorkTaskInstance.GetInstance().IsCurrentTask(workFlowInstanceId, workTaskId);
        }
        public string GetTaskDoneWhoMsg(string workTaskId, string workFlowInstanceId)   // 获取任务处理信息
        {
            return WorkTaskInstance.GetTaskDoneWhoMsg(workTaskId, workFlowInstanceId);
        }
        public string GetTaskOperDoneWhoMsg(string workTaskId, string workFlowInstanceId)
        {
            return WorkTaskInstance.GetTaskOperDoneWhoMsg(workTaskId, workFlowInstanceId); //获取当前审核信息
        }
        public DataTable GetTaskInstance(string workFlowInstanceId, string workTaskId)   //获得一个任务模板在流程实例中的所有任务实例
        {
            return WorkTaskInstance.GetInstance().GetTaskInstance(workFlowInstanceId, workTaskId);
        }
        public DataTable GetWorkTaskInstanceTable(string workTaskInstanceId)    //获取一条数据记录
        {
            return WorkTaskInstance.GetInstance().GetWorkTaskInstanceTable(workTaskInstanceId);
        }
        public DataTable GetWorkTaskLineView(string workFlowId)  //获取流程的所有任务连线视图
        {
            return WorkLine.GetInstance().GetWorkTaskLineView(workFlowId);
        }
        public string GetTaskToWhoMsg(string workTaskInstanceId)    //获取任务交给了谁
        {
            return WorkTaskInstance.GetTaskToWhoMsg(workTaskInstanceId);
        }
        public string GetResultMsg(string workTaskInstanceId)     // 获得任务成功提交信息
        {
            return WorkTaskInstance.GetResultMsg(workTaskInstanceId);
        }
        public DataTable GetAffixTable(string workflowInsId,bool satue)     // 获得任务节点附件列表
        {
            return AffixFiles.GetAffixTable(workflowInsId,satue);
        }
        public int DeleteAffix(string affixId)
        {
            return AffixFiles.DeleteAffix(affixId);
        }
        public void InsertAffixcrm(AffixFiles entity)
        {
            affixfiles.InsertAffixcrm(entity);
        }
        public string WorkTaskAssign(string userId, string assignUserId, string operatorInsId)        //指派任务
        {
            return WorkTaskInstance.WorkTaskAssign(userId, assignUserId, operatorInsId);
        }
        public DataTable GetTableEntity(string formid)    //获取自定义表单数据 
        {
            return WorkFlowInstance.GetInstance().GetTableEntity(formid);
        }
        public DataTable GetWorkflowdetail(string workFlowInstanceId)
        {
            return WorkFlowInstance.GetInstance().GetWorkflowdetail(workFlowInstanceId);
        }
        public DataTable GetUserAgency(string userid)
        {
            return WorkAgency.GetInstance().GetUserAgency(userid);
        }
        public DataTable GetDeptAgency(string userid)
        {
            return WorkAgency.GetInstance().GetDeptAgency(userid);
        }
        public void Insert(WorkAgencyEntity entity)    //流程代理插入
        {
            agency.Insert(entity);
        }
        public void Delete(string agencyid)    ///流程代理删除
        {
            agency.Delete(agencyid);
        }
        public DataTable GetWorkAgencyTable(string agencyid)   //获取流程代理 一条记录
        {
            return agency.GetWorkAgencyTable(agencyid);
        }
        public string TaskBackApplicant(string userId, string operatorInstanceId)      //退回至申请人
        {
            WorkFlowRuntime wfruntime = new WorkFlowRuntime();
            return wfruntime.TaskBackApplicant(userId, operatorInstanceId);
        }
        /// <summary>
        /// 查询流程层级
        /// </summary>
        /// <returns></returns>
        public DataTable SetHFWorkFlowClass()
        {
            return WorkFlowTemplate.GetInstance().SetHFWorkFlowClass();
        }

        /// <summary>
        /// 已授出的权限
        /// </summary>
        /// <param name="userId">用户Id</param>
        /// <returns>DataTable</returns>
        public DataTable GetToAccreditTable(string userId)
        {
            return AccreditUser.GetInstance().GetToAccreditTable(userId);
        }

        /// <summary>
        /// 被授予的权限
        /// </summary>
        /// <param name="userId">用户Id</param>
        /// <returns>DataTable</returns>
        public DataTable GetHaveAccreditTable(string userId)
        {
            return AccreditUser.GetInstance().GetHaveAccreditTable(userId);
        }
        /// <summary>
        /// 获得流程分类的所有子分类列表
        /// </summary>
        /// <param name="classId">分类Id</param>
        /// <returns>子分类table</returns>
        public DataTable GetChildClass(string classId)
        {
            return WorkFlowClass.GetInstance().GetChildClass(classId);
        }
     
        /// <summary>
        /// 获得流程分类下的所有流程列表
        /// </summary>
        /// <param name="classId">流程分类Id</param>
        /// <returns>流程列表</returns>
        public DataTable GetWorkFlowsByClassId(string classId)
        {
            return WorkFlowTemplate.GetInstance().GetWorkFlowsByClassId(classId);
        }

        /// <summary>
        /// 判断用户是否是该任务节点的操作者，如果不是不允许授权该任务.
        /// </summary>
        /// <param name="userId">用户Id</param>
        /// <param name="workFlowId">流程模板Id</param>
        /// <param name="workTaskId">任务模板Id</param>
        /// <returns></returns>
        public bool IsTaskOperator(string userId, string workFlowId, string workTaskId)
        {
            return AccreditUser.GetInstance().IsTaskOperator(userId, workFlowId, workTaskId);
        }
        /// <summary>
        /// 任务授权
        /// </summary>
        /// <param name="fromUserId">授权UserId</param>
        /// <param name="toUserId">被授权UserId</param>
        /// <param name="workflowId">流程模板Id</param>
        /// <param name="worktaskId">任务模板Id</param>
        /// <returns>操作是否成功的代码</returns>
        public string AssignAccredit(string fromUserId, string toUserId, string workFlowId, string workTaskId)
        {
            return AccreditUser.GetInstance().AssignAccredit(fromUserId, toUserId, workFlowId, workTaskId);
        }
        /// <summary>
        /// 删除授权
        /// </summary>
        /// <param name="accreditId">授权Id</param>
        public bool RemoveMoveAccredit(string accreditId, bool reults, DateTime AcceditCancelTime)
        {
           return AccreditUser.GetInstance().RemoveMoveAccredit(accreditId, reults,AcceditCancelTime);
        }

         /// <summary>
        /// 收回代理(所有)
        /// </summary>
        /// <param name="fromUserId"></param>
        /// <param name="toUserId"></param>
        public bool RemoveAccredit(string fromUserId, string toUserId, bool reults, DateTime AcceditCancelTime)
        {
            return AccreditUser.GetInstance().RemoveAccredit(fromUserId, toUserId, reults, AcceditCancelTime);
        }
        /// <summary>
        /// 指定人处理
        /// </summary>
        /// <param name="workTaskInstanceId"></param>
        public void DeleteByTaskInstance(string workTaskInstanceId)
        {
            WorkTaskInstanceNextOper.GetInstance().DeleteByTaskInstance(workTaskInstanceId);
        }
        /// <summary>
        /// 制定人插入
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public int NextOperInsert(WorkTaskInstanceNextOperEntity entity)
        {
            return WorkTaskInstanceNextOper.GetInstance().NextOperInsert(entity);
        }

        /// <summary>
        /// 已完成流程分类
        /// </summary>
        /// <returns></returns>
        public DataTable WorkFlowInstanceClass(string url, string satae)
        {
            return WorkFlowInstance.GetInstance().GetWorkFlowInstanceClass(url, satae);
        }
        /// <summary>
        /// 已完成的任务分类
        /// </summary>
        /// <returns></returns>
        public DataTable WorkTaskCompleteClass(string url, string satae)
        {
            return WorkFlowInstance.GetInstance().GetWorkTaskCompleteClass(url, satae);
        }
        /// <summary>
        ///我参与的任务分类
        /// </summary>
        /// <returns></returns>
        public DataTable WorkTaskInstanceClass(string url, string satae)
        {
            return WorkFlowInstance.GetInstance().GetWorkTaskInstanceClass(url, satae);
        }
        /// <summary>
        ///我的申请分类
        /// </summary>
        /// <returns></returns>
        public DataTable GetWorkFlowApplicationClass(string url, string satae)
        {
            return WorkFlowInstance.GetInstance().GetWorkFlowApplicationClass(url, satae);
        }
        /// <summary>
        ///我的审批分类
        /// </summary>
        /// <returns></returns>
        public DataTable GetWorkFlowApproveClass(string url, string satae)
        {
            return WorkFlowInstance.GetInstance().GetWorkFlowApproveClass(url, satae);
        }
        /// <summary>
        /// 待办任务分类
        /// </summary>
        /// <param name="url"></param>
        /// <param name="satae"></param>
        /// <returns></returns>
        public DataTable GetTaskInstanceClass(string url, string satae)
        {
            return WorkFlowInstance.GetInstance().GetTaskInstanceClass(url, satae);
        }
          /// <summary>
        /// 撤消分类统计
        /// </summary>
        /// <param name="url"></param>
        /// <param name="satae"></param>
        /// <returns></returns>
        public DataTable GetWofkFlowInstanceClass(string url, string satae)
        {
            return WorkFlowInstance.GetInstance().GetWofkFlowInstanceClass(url, satae);
        }
        
        /// <summary>
        /// 删除作废流程
        /// </summary>
        /// <param name="WorkFlowInstanceId">流程ID</param>
        /// <returns></returns>
        public bool DelectWofkFlowInstance(string WorkFlowInstanceId)
        {
            return WorkFlowInstance.GetInstance().DelectWofkFlowInstance(WorkFlowInstanceId);
        }
        /// <summary>
        /// 异常流程分类统计
        /// </summary>
        /// <param name="url"></param>
        /// <param name="satae"></param>
        /// <returns></returns>
        public DataTable GetWorkFlowErrorLogsClass(string url, string satae)
        {
            return WorkFlowInstance.GetInstance().GetWorkFlowErrorLogsClass(url, satae);
        }
        /// <summary>
        /// 统计流程是否阅读
        /// </summary>
        /// <param name="workTaskInstanceId"〉任务实例ID</param>
        /// <param name="userId">用户ID</param>
        /// <returns></returns>
        public int GetWorkFlowDisplay(string workTaskInstanceId, string userId)
        {
            return WorkFlowInstance.GetInstance().GetWorkFlowDisplay(workTaskInstanceId, userId);
        }
        /// <summary>
        /// 查询异常流程
        /// </summary>
        /// <param name="workTaskInstanceId"></param>
        /// <returns></returns>
        public DataTable GetWorkFlowErrorLogs(string workTaskInstanceId)
        {
            return WorkFlowInstance.GetInstance().GetWorkFlowErrorLogs(workTaskInstanceId);
        }
        /// <summary>
        /// 异常流程处理
        /// </summary>
        /// <returns></returns>
        public int GetWorkFlowErrorLogsColse(string type, string WorkTaskInstanceId, string WorkFlowInstanceId)
        {
            return WorkFlowInstance.GetInstance().GetWorkFlowErrorLogsColse(type, WorkTaskInstanceId,WorkFlowInstanceId);
        }
        /// <summary>
        /// 流程信息
        /// </summary>
        /// <returns></returns>
        public DataTable GetWorkFlow()
        {
            return WorkFlowTemplate.GetInstance().GetWorkFlow();
        }
        /// <summary>
        /// 获得流程的所有任务节点
        /// </summary>
        /// <returns></returns>
        public DataTable GetWorkTasksView()
        {
            return WorkTask.GetInstance().GetWorkTasksView();
        }

        /// <summary>
        /// 操作者
        /// </summary>
        /// <returns></returns>
        public DataTable TaskOperator()
        {
            return AccreditUser.GetInstance().TaskOperator();
        }

        /// <summary>
        /// 处理者信息
        /// </summary>
        /// <returns></returns>
        public DataTable GetOpercontent(string userId)
        {
            return AccreditUser.GetInstance().GetOpercontent(userId);
        }


        public bool IsLock(string worktaskid)
        {
            return OperatorInstance.GetInstance().IsLock(worktaskid);
        }

         /// <summary>
        /// 获得任务与流程实例视图
        /// </summary>
        /// <param name="workFlowInstanceId">流程实例Id</param>
        /// <returns>DataTable</returns>
        public DataTable GetWorkTaskInstanceView(string workTaskInstanceId)
        {
            return WorkTaskInstance.GetInstance().GetWorkTaskInstanceView(workTaskInstanceId);
        }

        /// <summary>
        /// 撤消状态
        /// </summary>
        /// <param name="WorkFlowInstanceId"></param>
        /// <param name="satae">撤消--6</param>
        /// <returns></returns>
        public bool UpdateWofkFlowInstance(string WorkFlowInstanceId, string satae)
        {
            return WorkFlowInstance.GetInstance().UpdateWofkFlowInstance(WorkFlowInstanceId, satae);
        }
        /// <summary>
        /// 获取任务实例节点的类型
        /// </summary>
        /// <param name="WorkTaskInstanceId">任务实例节点ID</param>
        /// <returns></returns>
        public  string GetWorkTaskTypeID(string WorkTaskInstanceId) 
        {
            return WorkTaskInstance.GetWorkTaskTypeID(WorkTaskInstanceId);
        
        }
        /// <summary>
        /// 获得流程名称
        /// </summary>
        /// <param name="workFlowId">流程Id</param>
        /// <returns></returns>
        public string GetWorkFlowCaption(string workFlowId)
        {
            return WorkFlowInstance.GetInstance().GetWorkFlowCaption(workFlowId);

        }
        public void SetWorkTaskInsStatus(string workTaskInstanceId)
        {
            WorkTaskInstance.SetWorkTaskInsStatus(workTaskInstanceId);
        }

        /// <summary>
        /// 添加流程规则
        /// </summary>
        /// <param name="AppSystem">系统</param>
        /// <param name="AppModel">模块</param>
        /// <param name="MethodName">方法名称</param>
        /// <param name="ClassName">参数实体</param>
        /// <param name="Iserver">服务接口</param>
        /// <param name="Address">服务地址</param>
        /// <param name="Parameter">参数</param>
        /// <param name="Staus">流程状态</param>
        /// <returns></returns>
        public int AddLoadIserver(string AppSystem, string AppModel, string MethodName, string ClassName, string Iserver, string Address, string Parameter, char Staus, string WorkFlowId, string ObjectFolder, List<ParameterEntity> parameter)
        {
            return LoadIserver.GetInstance().AddLoadIserver(AppSystem, AppModel, MethodName, ClassName, Iserver, Address, Parameter, Staus, WorkFlowId, ObjectFolder, parameter);
        }

        /// <summary>
        /// 对比流程规则
        /// </summary>
        /// <param name="workFlowInstanceId">流程实例ID</param>
        /// <param name="flowCaption">流程名称</param>
        /// <param name="workFlowId">流程ID</param>
        /// <returns></returns>
        public DataTable ContrastLoad(string workFlowInstanceId, string flowCaption, string workFlowId)
        {
            return LoadIserver.GetInstance().ContrastLoad(workFlowInstanceId, flowCaption, workFlowId);
        }

        /// <summary>
        /// 查询参数方法
        /// </summary>
        /// <param name="appModel">模块</param>
        /// <returns></returns>
        public DataTable GetParameter(string appModel)
        {
            return Parameter.GetInstance().GetParameter(appModel);
        }
        /// <summary>
        /// 指流程类型我已完成的任务,支持分页
        /// </summary>
        /// <param name="userId">WorkFlowClassID</param>
        /// <param name="userId">用户Id</param>
        /// <param name="pageIndex">页码</param>
        /// <param name="pageSize">页大小</param> 
        /// <returns>我已完成的任务表Entitys</returns>
        public DataTable GetCompletedWorkTaskByClass(string WorkFlowClassID, string userId, int pageIndex, int pageSize)
        {
            return WorkFlowInstance.GetInstance().GetCompletedWorkTaskByClass(WorkFlowClassID, userId, pageIndex, pageSize);
        }
        /// <summary>
        /// 指定流程类型的待办任务，支持分页
        /// </summary>
        /// <param name="userId">WorkFlowClassID</param>
        /// <param name="userId">UserId</param>
        /// <param name="pageIndex">页码</param>
        /// <param name="pageSize">页大小</param>
        /// <returns>返回待办任务列表</returns>
        public DataSet GetTodoWorkTaskByClass(string WorkFlowClassID, string userId, int pageIndex, int pageSize)
        {
            return WorkFlowInstance.GetInstance().GetTodoWorkTaskByClass(WorkFlowClassID, userId, pageIndex, pageSize);
        }
        /// <summary>
        /// 获取下一流程实例
        /// </summary>
        /// <param name="worktaskinsid"></param>
        /// <returns></returns>
        public DataTable GetWorktaskInsStatus(string worktaskinsid)
        {
            return OperatorInstance.GetInstance().GetWorktaskInsStatus(worktaskinsid);
        }

        /// <summary>
        /// 查询用户Guid
        /// </summary>
        /// <param name="userId">用户ID</param>
        /// <returns></returns>
        public string GetDatUser(string userId)
        {
            return LoadIserver.GetInstance().GetDatUser(userId);
        }

         /// <summary>
        /// 流程代理新增
        /// </summary>
        /// <param name="entitys">流程代理实例</param>
        /// <returns></returns>
        public bool AddAccreditUser(List<AccreditUserEntity> entitys)
        {
            return AccreditUser.GetInstance().AddAccreditUser(entitys);
        }

           /// <summary>
        /// 当前操作人代理状况
        /// </summary>
        /// <param name="accreditToUserId">操作人ID</param>
        /// <returns></returns>
        public DataTable GetOwnAccreditUser(string accreditToUserId)
        {
            return AccreditUser.GetInstance().GetOwnAccreditUser(accreditToUserId);

        }
            /// <summary>
        /// 其它操作人代理状况
        /// </summary>
        /// <param name="accreditToUserId">操作人ID</param>
        /// <returns></returns>
        public DataTable GetOtherAccreditUser(string accreditToUserId)
        {
            return AccreditUser.GetInstance().GetOtherAccreditUser(accreditToUserId);
        }

        /// <summary>
        /// 流程代理查询
        /// </summary>
        /// <param name="url">SQL语句条件</param>
        /// <returns></returns>
        public DataTable GetAccreditList(string url)
        {
            return AccreditUser.GetInstance().GetAccreditList(url);
        }
        /// <summary>
        /// 流程代理明细
        /// </summary>
        /// <param name="accreditToUserId">操作人ID</param>
        /// <param name="accreditFromUserId">被操作人ID</param>
        /// <returns></returns>
        public DataTable GetAccreditUserList(string accreditToUserId, string accreditFromUserId)
        {
            return AccreditUser.GetInstance().GetAccreditUserList(accreditToUserId, accreditFromUserId);
        }

          /// <summary>
        /// 流程类型
        /// </summary>
        /// <param name="accreditToUserId">操作人ID</param>
        /// <param name="accreditFromUserId">被操作人ID</param>
        /// <returns></returns>
        public DataTable GetWorkFlowCaptions(string accreditToUserId, string accreditFromUserId)
        {
            return AccreditUser.GetInstance().GetWorkFlowCaptions(accreditToUserId, accreditFromUserId);
        }

         /// <summary>
        /// 流程名称
        /// </summary>
        /// <param name="accreditToUserId">操作人ID</param>
        /// <param name="accreditFromUserId">被操作人ID</param>
        /// <returns></returns>
        public DataTable GetInstanceCaption(string accreditToUserId, string accreditFromUserId)
        {
            return AccreditUser.GetInstance().GetInstanceCaption(accreditToUserId, accreditFromUserId);
        }

        /// <summary>
        /// 查询所有流程
        /// </summary>
        /// <returns></returns>
        public DataTable GetWorkFlowClass()
        {
            return AccreditUser.GetInstance().GetWorkFlowClass();
        }


          /// <summary>
        /// 查询所有流程列表
        /// </summary>
        /// <returns></returns>
        public DataTable GetWorkFlowList()
        {
            return AccreditUser.GetInstance().GetWorkFlowList();
        }
        /// <summary>
        /// 转发的回写操作
        /// </summary>
        /// <param name="userId"></param>
        /// <param name="worktaskInsId"></param>
        public void SetOperatorInstance(string userId, string worktaskInsId)
        {
            OperatorInstance.SetOperatorInstance(userId, worktaskInsId);
        }
        public void UpdateTitle(string workFlowInstanceId, string title)
        {
            WorkFlowInstance.GetInstance().UpdateTitle(workFlowInstanceId, title);
        }

      
    }
}

